/*****************************************************************************
*  
*****************************************************************************/
#ifndef _VIDEOMODULE
#define _VIDEOMOUDUL

#ifdef _VIDEOMOUDULVAR
#define VCH_extern 
#else 
#define VCH_extern extern
#endif



typedef enum
{
	Pn_Stat_PAL,
	Pn_Stat_NoPAL,
	Pn_Stat_NTSC,
	Pn_Stat_NoNTSC
} _pndetstate;

typedef enum
{
	EVT_VIDEO_NONE,
	EVT_VIDEO_SOURCE,
	EVT_VIDEO_INFO,
	EVT_CAMERA_ENTER,
	EVT_CAMERA_EXIT,
	EVT_RGB_ENTER,
	EVT_RGB_EXIT,
	EVT_TV_ENTER,
	EVT_VIDEO_DETECT,
	EVT_VID_EMERGENCY_OFF,
	EVT_VID_MUTE_OFF,
	EVT_VID_MUTE_ON,
	EVT_VID_FRONT_SOURCE_SET,
	EVT_VID_REAR_SOURCE_SET,
	EVT_VID_BLUESCREEN
}VIDEO_EVT;

#define VIDEO_DETECT_INTERVAL T200MS_100
#define T800MS_4  200

///#define PAL_CYC_MIN     11111*2///22222
///#define PAL_CYC_MAX     9090*2///18180
///#define NTSC_CYC_MAX    7692*2///15384

//fcpu=1M
//fcyc=1us
//Cyc_PAL =1/50=20ms
//Cyc_NTSC=1/60=16.66ms
//PAL_CYC=20ms/1us=200000
//NTSC_CYC=16.66ms/1us=16666


#define FMS6501_ADDR    0x06  
#define FMS6501_CLAMP1	0x1D
#define FMS6501_CLAMP2 	0x1E

#define FMS6502_ADDR    0x06  
#define FMS6502_OUT12 	0x00
#define FMS6502_OUT34 	0x01
#define FMS6502_OUT56 	0x02

#define FMS6502_CLAMP 	0x03
#define FMS6502_GAIN  	0x04


#define OUT_PUT1_ADDR 0x01   
#define OUT_PUT2_ADDR 0x02
#define OUT_PUT3_ADDR 0x03
#define OUT_PUT4_ADDR 0x04
#define OUT_PUT5_ADDR 0x05
#define OUT_PUT6_ADDR 0x06
#define OUT_PUT7_ADDR 0x07
#define OUT_PUT8_ADDR 0x08
#define OUT_PUT9_ADDR 0x09

#define CHANNEL_ENABLE  0x80
#define CHANNEL_DISABLE 0x00

#define CHANNEL_GAIN_6db 0x00
#define CHANNEL_GAIN_7db 0x20
#define CHANNEL_GAIN_8db 0x40
#define CHANNEL_GAIN_9db 0x60

#define IN_PUTOFF 0x00
#define IN_PUT01   0x01
#define IN_PUT02   0x02
#define IN_PUT03   0x03
#define IN_PUT04   0x04
#define IN_PUT05   0x05
#define IN_PUT06   0x06
#define IN_PUT07   0x07
#define IN_PUT08   0x08
#define IN_PUT09   0x09
#define IN_PUT10   0x0A
#define IN_PUT11   0x0B
#define IN_PUT12   0x0C


#define  CVBS_OUT1_ADDR  			OUT_PUT1_ADDR
#define  CVBS_OUT2_ADDR  			OUT_PUT2_ADDR
#define	 FRONT_TFT_CVBS_ADDR  		OUT_PUT3_ADDR
#define  DETECT_VIDEO_ADDR  		FRONT_TFT_CVBS_ADDR///OUT_PUT4_ADDR

///#define  REAR_TFT_SYNC_ADDR  		FRONT_TFT_CVBS_ADDR////OUT_PUT5_ADDR

#define	 FRONT_TFT_R_ADDR			OUT_PUT4_ADDR
#define	 FRONT_TFT_G_ADDR			OUT_PUT5_ADDR
#define  FRONT_TFT_B_ADDR			OUT_PUT6_ADDR///new platform change. apollo

////#define REAR_CVBS_ADDR 			CVBS_OUT1_ADDR


#define NO_SOURCE 				IN_PUTOFF

#define DVD_CVBS_SOURCE 		IN_PUT01
#define AUX_TAIL_SOURCE		    IN_PUT02
#define AUX_PANEL_SOURCE		IN_PUT02///not used now 
#define CAMERA_SOURCE 			IN_PUT02



#define NAVI_CVBS_SOURCE 		NO_SOURCE
#define IPOD_VIDEO_SOURCE		NO_SOURCE

 #define NAVI_RED_SOURCE		IN_PUT03
 #define NAVI_GREEN_SOURCE		IN_PUT04
 #define NAVI_BLUE_SOURCE		IN_PUT05

#define DVD_RED_SOURCE 			IN_PUT06
#define DVD_GREEN_SOURCE 		IN_PUT07
#define DVD_BLUE_SOURCE 		IN_PUT08



/**********************************************************************/
//Global Variables and functions defined in video module
#define  DRGB	2
#define  RGB	1
#define  CVBS	0



#define AUTO		0

//VInputStd
#define NTSC		1			
#define PAL		2
#define SECAM	3
#define NTSC4	4
#define PALM		5
#define PALN		6
#define PAL60	7
#define NOSGL	8


ext   uchar pn;
///ext   uchar pnset;

#ifdef DEBUG_FMS6501
VCH_extern    uchar CH_FMS6501[12];
#endif
#define IS_VIDEO_EXIST		F_Video_Exist
#define CLR_VIDEO_EXIST		{F_Video_Exist=0;}
#define SET_VIDEO_EXIST		{F_Video_Exist=1;}

extern void TFT_Select_DVD_RGB(void);
#if VIDEO_SEL_IC==D_VIDEO_SEL_FMS6501
extern void TFT_Select_DVD_CVBS(void);
#endif
#if NAVI_FUNCTION
extern void TFT_Select_NAVI_RGB(void);
extern void Disp_NAVI_Menu(void);

#endif
extern void Video_System(uchar source);
extern void SetFrontVideo(uchar);
extern void Write_Rear_Source(uchar);
extern void Switch_Video_Detect(uchar source);
extern void Disp_MPEG_Menu(void);

extern void Disp_CVBS_Menu(void);
#if VIDEO_SEL_IC==D_VIDEO_SEL_FMS6501
extern void Select_Video_Source(uchar output_addr,uchar input_number,bool ON);
#define Select_Dvd_Sync		Select_Video_Source(FRONT_TFT_CVBS_ADDR,DVD_CVBS_SOURCE,ON);
#elif VIDEO_SEL_IC==D_VIDEO_SEL_FMS6502
extern void Vedio_Source_Sel(bool BeFrontSource,uchar CVBS_Src);
#endif

extern bool Navi_Menu_InFront(void);
extern void Pip_Source_Set(uchar Sub_Src);
#endif


